<?php require_once('../../Connections/cotiza.php'); ?>
<?php
session_start();
$campo    = $_GET['campo'];
$acc      = $_GET['acc'];
$vendedor = $_SESSION['usuario'];

mysql_select_db($database_cotiza, $cotiza);

if($acc == "search")
{
	$b = $_POST['busqueda'];
	$query = "SELECT solic_id, ad_name, solic_npcliente, solic_fecha FROM solic_mstr Left Outer Join ad_mstr ON ad_addr = solic_cliente 
	          WHERE (solic_id like '%$b%' or ad_name like '%$b%' or solic_npcliente like '%$b%') AND solic_user_c = '$vendedor' ORDER BY solic_id";
}
else
	$query = "SELECT solic_id, ad_name, solic_npcliente, solic_fecha FROM solic_mstr Left Outer Join ad_mstr ON ad_addr = solic_cliente WHERE solic_user_c = '$vendedor' ORDER BY solic_id";
	
$busqueda = mysql_query($query, $cotiza) or die(mysql_error());
$row = mysql_fetch_assoc($busqueda);
$totalRows = mysql_num_rows($busqueda);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>..:: Solicitudes ::..</title>
<link href="../../main.css" rel="stylesheet" type="text/css" />
<script language="javascript">
function genera_pdf(id)
{
	var especificaciones="top=0, left=0, toolbar=no,location=no, status=no,menubar=no,scrollbars=no, resizable=no, width=550,height=300"
 	window.open("../lib/pdf/demo/html2ps.php?process_mode=single&id="+id+"&URL=http://www.google.cl"+"&pixels=640&scalepoints=1&renderimages=1&renderlinks=1&renderfields=1&media=Letter&cssmedia=Screen&leftmargin=15&rightmargin=15&topmargin=15&bottommargin=15&watermarkhtml=Trazalum - Prueba&toc-location=before&smartpagebreak=1&pslevel=3&method=fpdf&pdfversion=1.5&output=1&convert=Convert+File",null,especificaciones)	
}
</script>
<style type="text/css">
<!--
.default_title {
	color: #FFF;
}
-->
</style>
</head>

<body onload="document.form1.busqueda.focus();">
<form id="form1" name="form1" method="post" action="solicitudes.php?campo=<?php echo $campo; ?>&acc=search">
  <table border="0" align="center">
    <tr>
      <td >B&uacute;squeda de Solicitudes:</td>
      <td ><input name="busqueda" class="default" size="20" autocomplete="off" /></td>
      <td ><input type="submit" value="Buscar" class="v8" /></td>
    </tr>
  </table>
</form>
<br />
<?php if($totalRows >0){?>
  <table width="623" border="1" align="center" cellpadding="2" cellspacing="0">
    <tr class="default_title">
      <td width="58" align="center" bgcolor="#0000CC">Id Solicitud</td>
      <td width="66" align="center" bgcolor="#0000CC">Fecha</td>
      <td width="214" align="center" bgcolor="#0000CC">Cliente</td>
      <td width="209" align="center" bgcolor="#0000CC">Producto</td>
      <td width="44" align="center" bgcolor="#0000CC">Opciones</td>
    </tr>
    <?php do { ?>
    <tr>
      <td width="58" height="24"><a href="javascript:window.opener.document.getElementById('<?php echo $campo; ?>').value= '<?php echo $row['solic_id']; ?>';window.opener.document.getElementById('<?php echo $campo; ?>').focus();window.close();"> <?php echo $row['solic_id']; ?> </a></td>
      <td width="66"> <?php echo $row['solic_fecha']; ?></td>
      <td width="214"> <?php echo $row['ad_name']; ?></td>
      <td width="209"><?php echo $row['solic_npcliente']; ?></td>
      <td width="44"><a href="javascript:genera_pdf('<?php echo $row['solic_id'];?>')"><img src="../img/page_white_acrobat.png" width="16" height="16" border="0" /></a></td>
    </tr>
      <?php } while ($row = mysql_fetch_assoc($busqueda)); ?>
  </table>
<?php }?>
</body>
</html>
<?php 
mysql_close($cotiza);
?>